package net.qunzhi.modules.cms.service.impl;

import net.qunzhi.modules.app.dto.UserRoleDto;
import net.qunzhi.modules.cms.query.WxUserInfoQuery;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import net.qunzhi.common.utils.BaseQuery;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.qunzhi.common.utils.PageUtils;
import net.qunzhi.common.utils.Query;

import net.qunzhi.modules.cms.dao.TbUserInfoDao;
import net.qunzhi.modules.cms.entity.TbUserInfoEntity;
import net.qunzhi.modules.cms.service.TbUserInfoService;


@Service("tbUserInfoService")
public class TbUserInfoServiceImpl extends ServiceImpl<TbUserInfoDao, TbUserInfoEntity> implements TbUserInfoService {

    @Override
    public PageUtils queryPage(WxUserInfoQuery query) {
        IPage<TbUserInfoEntity> page = this.page(
                new Query<TbUserInfoEntity>().getPage(query),
                new QueryWrapper<TbUserInfoEntity>()
                        .like(StringUtils.isNotBlank(query.getUsername()), "username", query.getUsername())
        );

        return new PageUtils(page);
    }

    @Override
    public UserRoleDto getUserRoleListByOpenId(String openId) {
        return this.baseMapper.getUserRoleListByOpenId(openId);
    }

}